package com.yiyuan.system.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.yiyuan.common.base.BaseDao;
import com.yiyuan.system.dao.IUserPriDao;
import com.yiyuan.system.model.UserPri;

@Repository("userPriDao")
public class UserPriDaoHbImpl extends BaseDao implements IUserPriDao {
	public void add(UserPri userPri) {
		this.getHibernateTemplate().save(userPri);
	}

	@SuppressWarnings("unchecked")
	public List<UserPri> findListByUserId(Integer userId) {
		Session session = this.getSession();
		Query query = session.createQuery("from UserPri where userId=:userId");
		query.setInteger("userId", userId);
		List<UserPri> list = query.list();
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<UserPri> findListByPriId(Integer priId) {
		Session session = this.getSession();
		Query query = session.createQuery("from UserPri where priId=:priId");
		query.setInteger("priId", priId);
		List<UserPri> list = query.list();
		return list;
	}

	public void delete(UserPri userPri) {
		this.getHibernateTemplate().delete(userPri);
	}
}
